import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/enums/index.dart';
import 'package:geomancy/styles/index.dart';
import 'package:geomancy/tools/utils.dart';
import 'package:go_router/go_router.dart';

class CommonHeader {
  static appBar({
    required BuildContext context,
    String? title,
    ThemeEnum? theme = ThemeEnum.light,
    Color? backgroundColor,
    bool showActions = true
  }) {
    return AppBar(
      title: title != null ? Text(title, style: TextStyle(fontSize: 30.sp)) : null,
      backgroundColor: backgroundColor ?? ColorStyle.pageDefaultColor,
      leading: GestureDetector(
        onTap: () {
          Navigator.pop(context);
        },
        child: Container(
          color: Colors.transparent,
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.only(left: 26.w),
          child: Image.asset(theme == ThemeEnum.dark ? 'assets/icons/icon_app_back_arrow_white.png' : 'assets/icons/icon_app_back_arrow.png', height: 36.w),
        ),
      ),
      actions: [
        if (showActions)
          GestureDetector(
            onTap: () {
              Utils.shake();
              context.push('/');
            },
            child: Container(
              color: Colors.transparent,
              padding: EdgeInsets.fromLTRB(40.w, 0.w, 32.w, 0.w),
              alignment: Alignment.center,
              child: Image.asset('assets/icons/icon_home.png', width: 36.w,),
            ),
          )
      ],
    );
  }
}